package com.tdam2011.grupo06.network;

import java.util.Date;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import com.tdam2011.grupo06.model.MensajeBob;

public class BobMessageParserSax {
	
	public BobMessageParserSax()
	{
		
	}
	
	public List<MensajeBob> parseMessages(String user, String password, Date timeFilter)
	{
		SAXParserFactory factory = SAXParserFactory.newInstance();

		try
		{
			SAXParser parser = factory.newSAXParser();
			BobMessageHandler handler = new BobMessageHandler();
			parser.parse(Networking.requestGetMessages(user, password, timeFilter), handler);
			return handler.getMensajes();
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}
}
